/**
 * 	 Copyright (c) 2008, 2009 Lukas Zaruba
 * 
 *   This file is part of UniAnalyzer (Universal Analyzer).
 *
 *   UniAnalyzer is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU Lesser General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   UniAnalyzer is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU Lesser General Public License for more details.
 *
 *   You should have received a copy of the GNU Lesser General Public License
 *   along with UniAnalyzer. If not, see <http://www.gnu.org/licenses/>.
 */

package net.zarubsys.unianalyzer.dataminers.lpt.internal.result.impl;

import java.io.Serializable;
import java.util.Arrays;
import java.util.Date;
import java.util.List;

import net.zarubsys.unianalyzer.dataminers.lpt.results.IResult;
import net.zarubsys.unianalyzer.dataminers.lpt.triggers.TriggerDescription;

/**
 * Result
 *
 * @author  &lt;A HREF=&quot;mailto:lukas.zaruba@media-solutions.cz&quot;&gt;Lukas Zaruba&lt;/A&gt;, MEDIA SOLUTIONS CZECH REPUBLIC Ltd.
 * @version $Revision$ $Date$
 */
public class Result implements Serializable, IResult {

	private static final long serialVersionUID = 2771880713464164751L;

	private int[] content;
	
	private final Date dateOfCreation;
	private final int address;
	private final int desiredFrequency;
	private final String desiredFrequencyUnits;
	private final TriggerDescription triggerDescription;
	private final int resultMask;
	private final List<String> pinNames;
	
	private String note;
	private long nanoLength;

	public Result(int desiredFrequency, String desiredFrequencyUnits, int address, int resultMask, List<String> pinNames, TriggerDescription trigger) {
		this.dateOfCreation = new Date();
		this.desiredFrequency = desiredFrequency;
		this.address = address;
		this.triggerDescription = trigger;
		this.desiredFrequencyUnits = desiredFrequencyUnits;
		this.resultMask = resultMask;
		this.pinNames = pinNames;
	}
	
	public String getNote() {
		return note;
	}

	public void setNote(String note) {
		this.note = note;
	}

	public String getDesiredFrequencyUnits() {
		return desiredFrequencyUnits;
	}
	
	public void setContent(int[] content) {
		this.content = Arrays.copyOf(content, content.length);
	}

	public int[] getContent() {
		return Arrays.copyOf(content, content.length);
	}
	
	public int getContentAtPosition(int address) {
		return content[address];
	}

	public Date getDateOfCreation() {
		return new Date(dateOfCreation.getTime());
	}

	public int getDesiredFrequency() {
		return desiredFrequency;
	}

	public int getAddress() {
		return address;
	}

	public float getRealFrequency() {
		float secLength = nanoLength / (float) (1000 * 1000 * 1000);
		return content.length / secLength;
	}
	
	public void setNanoLength(long nanoLength) {
		this.nanoLength = nanoLength;
	}

	public TriggerDescription getTriggerDescription() {
		return triggerDescription;
	}
	
	public int getSamplesCount() {
		return content.length;
	}

	public int getResultMask() {
		return resultMask;
	}
	
	public List<String> getPinNames() {
		return pinNames;
	}

}


/*
 * $Log$
 */